package com.dg11185.nearshop.net.request;

import com.dg11185.libs.network.http.client.HttpRequest;
import com.dg11185.libs.utils.MD5.MD5Utils;
import com.dg11185.nearshop.app.Constants;
import com.dg11185.nearshop.net.HttpCacheRequest;
import com.dg11185.nearshop.net.response.GetBrandListResponse;

/**
 * 获取精选商家（连锁商家）
 * 
 * @author：Daibo
 * @time：2014-5-16 下午1:36:49
 */
public class GetBrandListRequest extends HttpCacheRequest<GetBrandListResponse> {

    public final static String PAGE_NUM = "pageNumber";// 当前页
    public final static String PAGE_SIZE = "pageSize";// 每页数量
    public final static String ORDER_NAME = "orderName";// 排序字段
    public final static String ORDER_TYPE = "orderType";// 0.升序，1.降序

    public final static String AREA_NUM = "areaNum";
    public final static String TOKEN = "chshToken";

    public GetBrandListRequest(String areaNum) {
        super(Constants.ADDRESS, Constants.getBrandList);
        addParam(AREA_NUM, areaNum);
        addParam(TOKEN, Constants.TOKEN);
        setIsCreateFloder(true);
        // addParam("chshSign", MD5Utils.getMD5Str(getParams(),
        // Constants.MD5_key));
    }

    /**
     * <可选参数> <param name="pageNumber">当前页</param> <param
     * name="pageSize">每页数量</param> <param name="orderName">排序字段</param> <param
     * name="orderType">0.升序，1.降序</param> </可选参数>
     */
    public GetBrandListRequest add(String key, String value) {
        addParam(key, value);
        return this;
    }

    public GetBrandListRequest encryption() {
        addParam("chshSign", MD5Utils.getMD5Str(getParams(), Constants.MD5_key));
        return this;
    }

    @Override
    protected GetBrandListResponse parseJson(String response) throws Exception {
        GetBrandListResponse r = new GetBrandListResponse();
        r.parseJson(response);
        return r;
    }

}
